import { FunctionButton } from "./FunctionButton";
import { ResFileConst } from "../../resource/ResFileConst";
import { Language } from "../../../../extend/language/Language";
import { EQuestionFuncCode } from "../../../../Message/Public/EQuestionFuncCode";
import { QuestionDataTool } from "./QuestionDataTool";
import { SQuestionFunc } from "../../../../Message/Public/SQuestionFunc";
//class FunctionButtonPanel
    
    export  class FunctionButtonPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._correctBtn = new FunctionButton("", 110, 47, ResFileConst.QuesCorrect);
            this._correctBtn.x = 0;
            this._correctBtn.toolTip = Language.getString(35622);
            this._correctBtn.funcCode = EQuestionFuncCode._EQuestionFuncCodeRight;
            addChild(this._correctBtn);
            this._finalPkBtn = new FunctionButton("", 110, 47, ResFileConst.QuesFinalPk);
            this._finalPkBtn.x = 120;
            this._finalPkBtn.toolTip = Language.getString(35623);
            this._finalPkBtn.funcCode = EQuestionFuncCode._EQuestionFuncCodeRemainTwo;
            addChild(this._finalPkBtn);
            this._doubleBtn = new FunctionButton("", 110, 47, ResFileConst.QuesDouble);
            this._doubleBtn.x = 240;
            this._doubleBtn.toolTip = Language.getString(35624);
            this._doubleBtn.funcCode = EQuestionFuncCode._EQuestionFuncCodeDouble;
            addChild(this._doubleBtn);
            return;
        }

        public updateFunctionNum(arg1: Array<any>=null): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=0;
            var loc4=0;
            var loc5=0;
            if (arg1 == null && !(QuestionDataTool.sQuestionPlayerInfo == null)) 
            {
                arg1 = QuestionDataTool.sQuestionPlayerInfo.funcs;
            }
            if (arg1 == null) 
            {
                return;
            }
            var loc6=0;
            while (loc6 < arg1.length) 
            {
                loc1 = arg1[loc6] as SQuestionFunc;
                loc4 = loc1.totalTimes;
                loc2 = loc1.usedTimes;
                loc3 = loc4 - 2;
                if ((loc5 = loc1.funcCode) != EQuestionFuncCode._EQuestionFuncCodeRight) 
                {
                    if (loc5 != EQuestionFuncCode._EQuestionFuncCodeRemainTwo) 
                    {
                        if (loc5 == EQuestionFuncCode._EQuestionFuncCodeDouble) 
                        {
                            this._doubleBtn.updateFunctionNum(loc2, loc4, loc3);
                        }
                    }
                    else 
                    {
                        this._finalPkBtn.updateFunctionNum(loc2, loc4, loc3);
                    }
                }
                else 
                {
                    this._correctBtn.updateFunctionNum(loc2, loc4, loc3);
                }
                ++loc6;
            }
            return;
        }

        public setFuncBtnEnable(arg1: Boolean): void
        {
            if (QuestionDataTool.correctFuncTimes > 0) 
            {
                this._correctBtn.buttonEnable = arg1;
            }
            else 
            {
                this._correctBtn.buttonEnable = false;
            }
            if (QuestionDataTool.remainTwoFuncTimes > 0) 
            {
                this._finalPkBtn.buttonEnable = arg1;
            }
            else 
            {
                this._finalPkBtn.buttonEnable = false;
            }
            if (QuestionDataTool.doubleFuncTimes > 0) 
            {
                this._doubleBtn.buttonEnable = arg1;
            }
            else 
            {
                this._doubleBtn.buttonEnable = false;
            }
            return;
        }

        /* internal */ /* var */_correctBtn: FunctionButton;

        /* internal */ /* var */_finalPkBtn: FunctionButton;

        /* internal */ /* var */_doubleBtn: FunctionButton;
    }
